﻿/*
 * Created by SharpDevelop.
 * User: ratul
 * Date: 3/2/2010
 * Time: 7:55 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections;
using System.Collections.Generic;

namespace H264Impl.NET.Decoder
{
	/// <summary>
	/// Description of CodedPicture.
	/// </summary>
	public class CodedPicture
	{
		public CodedPicture(AccessUnit parentAccessUnit)
		{
			this.parentAccessUnit = parentAccessUnit;
		}
		
		enum CodedPictureType
		{
			IDR,   //Iinstantaneous Decoding Refresh
			NonIDR
		}
		
		AccessUnit parentAccessUnit;
		List<Slice.BaseSlice> sliceList;
		CodedPictureType codedPictureType;
		List<NAL.NALUnit> NALUnitList;
		
		public void parseSliceLayerWithoutPartitioningRBSP(NAL.NALUnit _NALUnit, BitStream RBSP, UInt32 firstMbInSlice, UInt32 sliceType, UInt32 picParameterSetId)
		{
			Slice.BaseSlice slice;
			if(sliceType==0 || sliceType==5)
				slice = new Slice.PSlice(this);
			else if(sliceType==1 || sliceType==6)
				slice = new Slice.BSlice(this);
			else if(sliceType==2 || sliceType==7)
				slice = new Slice.ISlice(this);
			else if(sliceType==3 || sliceType==8)
				slice = new Slice.SPSlice(this);
			else if(sliceType==4 || sliceType==9)
				slice = new Slice.SISlice(this);
			else 
				throw new H264ImplConformanceException();
			
			sliceList.Add(slice);
			
			slice.parseSliceLayerWithoutPartitioningRBSP(_NALUnit, RBSP, firstMbInSlice, picParameterSetId);
			
			
		}
		
		public bool getSeparateColorPlaneFlag()
		{
			return parentAccessUnit.getSeparateColorPlaneFlag();
		}
		
		public UInt32 getPicOrderCntType()
		{
			return parentAccessUnit.getPicOrderCntType();
		}
		
		public UInt32 getLog2MaxPicOrderCntLsbMinus4()
		{
			return parentAccessUnit.getLog2MaxPicOrderCntLsbMinus4();
		}
		
				public UInt32 getLog2MaxFrameNumMinus4()
		{
			return parentAccessUnit.getLog2MaxFrameNumMinus4();
		}
		
		public bool getFrameMbsOnlyFlag()
		{
			return parentAccessUnit.getFrameMbsOnlyFlag();
		}
		
		
		public bool getBottomFieldPicOrderInFramePresentFlag()
		{
			return parentAccessUnit.getBottomFieldPicOrderInFramePresentFlag();
		}
		
		public bool getDeltaPicOrderAlwaysZeroFlag()
		{
			return parentAccessUnit.getDeltaPicOrderAlwaysZeroFlag();
		}
		
		public bool getRedundantPicCntPresentFlag()
		{
			return parentAccessUnit.getRedundantPicCntPresentFlag();
		}
	}
	
}
